﻿<?php 
//error_reporting(E_ERROR|E_PARSE);
session_start();
if($_SESSION["islogin"]!=='igiveyouthepower'){
echo "<script language=JavaScript>\r\n";
echo "alert('请先登录!');\r\n";
echo "location.href='../index.php'\r\n";
echo "</script>";
}else{
require_once('../config.php');
?>
<?php 
$conn = mysqli_connect($cfg_dbhost,$cfg_dbuser,$cfg_dbpwd,$cfg_dbname);
$lang=$_GET["lang"];
$platform=$_GET["platform"];
$bname=$_GET["bname"];
$oldstr=$_POST["oldstr"];
$newstr=$_POST["newstr"];
$user_name=$_SESSION["managername"];
if($_REQUEST["lang"]==""||!isset($_REQUEST["lang"])){$lang="products";}else{$lang=$_REQUEST["lang"];}
if(empty($platform)){$platform="AliExpress";}
if(!empty($oldstr)){
$result=mysqli_query($conn,"select * from ph_".$lang." where bname='".$bname."' and platform='".$platform."'");
while($row= mysqli_fetch_array($result)){
$proname=$row["proname"];
$des=$row["des"];
$keywords=$row["keywords"];
$content=$row["content"];
$sketch=$row["sketch"];
$proname=str_replace($oldstr,$newstr,$proname);
$des=str_replace($oldstr,$newstr,$des);
$keywords=str_replace($oldstr,$newstr,$keywords);
$content=str_replace($oldstr,$newstr,$content);
$sketch=str_replace($oldstr,$newstr,$sketch);
$sql = "update ph_".$lang." set proname='".$proname."',content='".$content."',keywords='".$keywords."',des='".$des."',sketch='".$sketch."' where id='".$row["ID"]."'";
mysqli_query($conn,$sql);
echo $proname."  替换完成!<br/>";
}
}
echo "<script language=JavaScript>\r\n";
echo "alert('全部替换完成!');\r\n";
echo "location.href='bigcategory.php?platform=".$platform."&lang=".$lang."&bname=".$bname."'\r\n";
echo "</script>";
?>
<?php }?>